﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using Common.Logging;
using WuDada.Core.Post;
using WuDada.Core.Post.Domain;
using WuDada.Core.Post.Service;
using WuDada.Core.SystemApplications.Domain;
using System.Web;

public partial class admin_UC01_0101 : System.Web.UI.Page
{
    private ILog m_Log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
    private PostFactory m_PostFactory;
    private IPostService m_PostService;
    private WebLogService m_WebLogService;

    //我們的背景 m_Mode=1
    private int m_Mode = 1;

    protected void Page_Load(object sender, EventArgs e)
    {
        m_WebLogService = new WebLogService();
        m_PostFactory = new PostFactory();
        m_PostService = m_PostFactory.GetPostService();

        if (!IsPostBack)
        {
            ShowMode();
            LoadVOToUI();
        }
    }

    private void ShowMode()
    {
        if (m_Mode == 0)
        {
            btnSave.Visible = false;

        }
        else
        {
            btnSave.Visible = true;

        }
    }

    private void LoadVOToUI()
    {
        PostVO postVO = m_PostService.GetPostById(m_Mode);
        //UIHelper.FillUI(pnlContent, postVO);
        ckeContent.value = postVO.HtmlContent;
    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        PostVO postVO = m_PostService.GetPostById(m_Mode);
        //UIHelper.FillVO(pnlContent, postVO);
        postVO.HtmlContent = ckeContent.value;
        m_PostService.UpdatePost(postVO);
        m_WebLogService.AddSystemLog(MsgVO.Action.修改, postVO);
        ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "js", JavascriptUtil.AlertJS(MsgVO.UPDATE_OK), false);
    }
}


